function Bird() {
    this.alive = true;
    this.success = false;
    this.level = 1;
    this.score = 0;
    this.extraScore = 0;
    this.totalScore = 0;
    this.btn = 0;

    this.x = width / 2;
    this.y = height - 50;

    this.gravity = 0.5;
    this.velocity = 0;

    this.raduis = 16;

    this.show = function () {
        fill(255);
        ellipse(this.x, this.y, this.raduis, this.raduis);

        var m = map(Math.abs(this.x - width / 2), 0, width/2, PI/2, 0);

        this.extraScore += Math.sin(m) * 5;

        text('等级: ' + this.level.toString(), 10, 20);
        text('移动得分: ' + this.score.toString(), 10, 35);
        text('等级奖励: ' + ((this.level - 1) * 100).toString(), 10, 50);
        text('控制奖励: ' + (this.extraScore.toFixed()).toString(), 10, 65);

        this.totalScore = (this.score + (this.level - 1) * 100 + this.extraScore).toFixed().toString();
        text('总得分: ' + this.totalScore, 10, 80);
        text('按键计数: ' + this.btn, 10, 100);
    };

    this.update = function () {
        this.velocity += this.gravity;
        this.x += this.velocity;

        this.y -= 1;
        this.score++;

        if (this.y < this.raduis / 2) {
            this.success = true;
            this.score += 100;
        }

        if (this.x < this.raduis || this.x > (width - this.raduis)) {
            this.alive = false;
        }
    };

    this.renew = function () {
        this.alive = true;
        this.success = false;
        this.level = 1;
        this.score = 0;
        this.extraScore = 0;

        this.gravity = this.level * 0.2 + 0.3;
        this.velocity = 0;

        this.x = width / 2;
        this.y = height - 50;
    };

    this.upgrade = function () {
        this.alive = true;
        this.success = false;
        this.level += 1;

        this.gravity = this.level * 0.2 + 0.3;
        this.velocity = 0;

        this.x = width / 2;
        this.y = height - 50;
    };

    this.up = function () {
        this.gravity = -Math.abs(this.gravity);
    };

    this.down = function () {
        this.gravity = Math.abs(this.gravity);
    }
}
